<template>
  <div class="shop-box" :style="boxStyle">
    <div class="item" v-for="(v, i) in dataObj" :key="i" :style="itemStyle">
      <div class="img-box">
        <img :src="v.smallImg" alt="" @click="next(v)" />
      </div>
      <p class="pro-name">{{ v.name }}</p>
      <p class="pro-enname">{{ v.enname }}</p>
      <p class="pro-price">￥{{ v.price }}</p>
      <div class="bottom-slot" @click="delCollect(i)" v-if="isDel"></div>
      <slot name="hot"></slot>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  methods: {
    next(v) {
      this.$router.push({ name: "ShopMes", query: { pid: v.pid } });
    },
    delCollect(i) {
      this.$emit("delData", i);
    },
  },
  props: {
    dataObj: {
      default: "",
    },
    boxStyle: {
      default: "",
    },
    itemStyle: {
      default: "",
    },
    isDel: {
      type: Boolean,
      default: false,
    },
  },
};
</script>

<style lang="less" scoped>
.shop-box {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  // justify-content: space-between;
  padding: 0 20px;
  box-sizing: border-box;
  margin-bottom: 50px;
  overflow: hidden;
  // background-color: #fff;
  .item {
    width: calc(~"100% / 2 - 10px");
    text-align: center;
    padding: 10px 2px;
    font-size: 16px;
    margin-bottom: 10px;
    border-radius: 10px;
    background-color: #fff;
    position: relative;
    .pro-enname {
      font-size: 12px;
    }
    p {
      margin: 2px 0;
      text-align: left;
      padding-left: 10%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .img-box {
      width: 80%;
      margin: 0 auto;
      img {
        width: 100%;
      }
    }
    .pro-price {
      color: rgb(12, 52, 186);
      font-weight: bold;
    }
    .bottom-slot {
      width: 20px;
      height: 20px;
      background-image: url(../assets/images/回收站.png);
      background-size: 100% 100%;
      background-repeat: no-repeat;
      position: absolute;
      bottom: 10px;
      right: 10px;
      text-align: center;
      cursor: pointer;
    }
  }
}
</style>